package com.ch.home.controller.dishController;

import com.ch.home.bean.DishCustom;
import com.ch.home.service.serviceImpl.restDishServiceImpl.DishCustomServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * Created by CHEN on 2019/8/27.
 */
@RestController
@RequestMapping("/dish/custom")
public class DishCustomController {

    @Autowired
    DishCustomServiceImpl dishCustomService;

    /**
     * 拿到预览信息，目前可以不写
     * @return
     */
    @PostMapping("/getPreview")
    public HashMap getPreview(){
        return null;
    }


 /**
     *
     * @return
     */
    @PostMapping("/getAll")
    public HashMap getAllInfo(@RequestParam(required = false) Integer dishId){
        HashMap<Object, Object> result;
        result = dishCustomService.getAll(new DishCustom(null,dishId,null,null,null));
        return result;
    }

    @PostMapping("/add")
    public HashMap addCustom(@RequestParam(required = false) Integer dishId,@RequestParam(required = false) String customContent){

        HashMap<Object, Object> result;
        result = dishCustomService.add(new DishCustom(null,dishId,customContent,null,null));
        return result;
    }


    @PostMapping("/update")
    public HashMap updateCustom(@RequestParam(required = false) Integer customId,@RequestParam(required = false) Integer dishId,@RequestParam(required = false) String customContent){
        HashMap<Object, Object> result;
        result = dishCustomService.update(new DishCustom(customId,dishId,customContent,null,null));
        return result;
    }
    //comment可以暂时不写




}
